package com.amigo.online.provider.manager.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.amigo.online.provider.manager.mapper.VideoMapper;
import com.amigo.online.provider.manager.model.entity.Comment;
import com.amigo.online.provider.manager.service.VideoCommentService;

@Service
@Transactional
public class VideoCommentServiceImpl implements VideoCommentService {

    @Autowired
    private VideoMapper videoMapper;

    @Override
    public Map<String, Object> findByVideoId(Long videoId, Integer page) {
        if (page == null || page <= 0) {
            page = 1;
        }
        Integer startNum = (page - 1) * 10;
        List<Comment> list = videoMapper.getCommentList(videoId, startNum);
        Integer count = videoMapper.getCountByVideoId(videoId);
        Map<String, Object> map = new HashMap<>();
        map.put("list", list);
        map.put("count", count);
        return map;
    }


    @Override
    public boolean disappearComment(Long id, Integer status) {
        if (videoMapper.disappearComment(id, status) > 0) {
            return true;
        }
        return false;
    }


}
